home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8406 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: news.sni.de!news
  2. From: Josef Moellers <mollers.pad@sni.de>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Calling a Function Twice from a printf statement.
  5. Date: 4 Mar 1996 09:33:48 GMT
  6. Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
  7. Message-ID: <4hedds$bbt@nervous.pdb.sni.de>
  8. References: <4he6q9$6r6@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: uranium.pdb.sni.de
  10. X-Newsreader: NN version 6.5.0 #2
  11.  
  12. In <4he6q9$6r6@newsbf02.news.aol.com> razine@aol.com (Razine) writes:
  13.  
  14. >int num(int index) {
  15. >   int return_number;
  16. >   
  17. >   switch(index) {
  18. >       case 0 : return_number=0;
  19. >       case 1 : return_number=1;
  20. >                       }
  21. >   return(return_number);
  22. >}
  23.  
  24. My compiler says "[warning]:   Flow between cases"!
  25.  
  26. And the program prints
  27.     First Number is 1 , the Second s 1 
  28. which is consistent with the error message.
  29.  
  30. You need to put "break;" statements after each of the cases in the
  31. switch:
  32.  
  33.    switch(index) {
  34.        case 0 : return_number=0; break;
  35.        case 1 : return_number=1; break;
  36.                }
  37.  
  38. Happy switching,
  39.  
  40. Josef
  41. --
  42. Josef Moellers        work: mollers.pad@sni.de
  43.             home: josef@firefox.pb.owl.de
  44.